package com.springbootmybatis.service.Impl;

import com.springbootmybatis.mapper.BookMapper;
import com.springbootmybatis.pojo.Book;
import com.springbootmybatis.service.BookService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class BookServiceImpl implements BookService {
	@Resource
	private BookMapper bookMapper;
	@Override
	public List<Book> findAllBook() {
		return bookMapper.findAllBook();
	}

	@Override
	public Book findBookById(Integer id) {
		return bookMapper.findBookById(id);
	}

	@Override
	public List<Book> searchBooks(Book book) {
		return bookMapper.searchBooks(book);
	}

	@Override
	@Transactional
	public Integer addBook(Book book) {
		return bookMapper.addBook(book);
	}

	@Override
	@Transactional
	public Integer updateBook(Book book) {
		return bookMapper.updateBook(book);
	}

	@Override
	@Transactional
	public Integer deleteById(Integer id) {
		return bookMapper.deleteById(id);
	}
}
